package com.baizan.daka.ui.fragment

import android.os.Bundle
import com.baizan.daka.base.BasePageListFragment
import com.baizan.daka.mvp.model.bean.PakeageInfoBean
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.ui.adapter.MyPackageAdapter
import com.baizan.daka.ui.contract.MyPackageContract
import com.baizan.daka.ui.presenter.MyPackagePresenter

class MyPackageFragment : BasePageListFragment<MyPackagePresenter, MyPackageAdapter>(),
    MyPackageContract.View {
    var usedFlag :Int? = null

    companion object {
        fun newInstance(usedFlag: Int?) :MyPackageFragment{
            val fragment = MyPackageFragment()
            usedFlag?.let {
                val bundle = Bundle()
                bundle.putInt("key", usedFlag)
                fragment.arguments = bundle
            }
            return fragment
        }
    }

    override fun initData() {
        super.initData()
        usedFlag = arguments?.getInt("key")
    }

    override fun onRefresh() {
        presenter?.loadMyVipList(mCurrentPageNo,usedFlag)
    }

    override fun onLoadMore() {
        presenter?.loadMyVipList(mCurrentPageNo,usedFlag)
    }

    override fun initAdapter(): MyPackageAdapter = MyPackageAdapter()

    override fun initPresenter(): MyPackagePresenter = MyPackagePresenter(this)

    override fun initView() {

    }

    override fun start() {
        presenter?.loadMyVipList(mCurrentPageNo,usedFlag)
    }


    override fun loadMyVipList(data: BasePageResponse<PakeageInfoBean>) {
        getDatasSuccess(data)
    }

}